package com.duowenlvshi.boot.controller;

import com.duowenlvshi.boot.domain.User;
import com.duowenlvshi.boot.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author hbin
 * @date 2020-03-08 15:36
 */
@RestController
@RequestMapping("/rest")
public class RController {

    @Autowired
    private IUserService userService;

    @RequestMapping("/getdata")
    public Object getdata(){
        return userService.selectAll();
    }

    @GetMapping("/selectAll")
    public Object selectAll(){
        return userService.selectAll();
    }

    @GetMapping("/selectByPrimaryKey/{id}")
    public Object selectByPrimaryKey(@PathVariable Long id){
        return userService.selectByPrimaryKey(id);
    }

    @PostMapping("/insert")
    public Object insert(User user){
        userService.insert(user);
        return "保存成功";
    }

    @PutMapping("/updateByPrimaryKey")
    public Object updateByPrimaryKey(User user){
        userService.updateByPrimaryKey(user);
        return "更新成功";
    }

}
